package com.ruoyi.zxjd.work.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zxjd.work.domain.WorkTemplateTable2;
import com.ruoyi.zxjd.work.domain.bo.WorkProgressBO;
import com.ruoyi.zxjd.work.service.IWorkTemplateTable2Service;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 运用“四种形态”纪律审查情况Controller
 * 
 * @author lcc
 * @date 2021-02-22
 */
@Controller
@RequestMapping("/work/templatetable2")
public class WorkTemplateTable2Controller extends BaseController
{
    private String prefix = "work/templatetable2";

    @Autowired
    private IWorkTemplateTable2Service workTemplateTable2Service;

    @RequiresPermissions("work:templatetable2:view")
    @GetMapping()
    public String templatetable2()
    {
        return prefix + "/templatetable2";
    }

    /**
     * 查询运用“四种形态”纪律审查情况列表
     */
    @RequiresPermissions("work:templatetable2:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WorkTemplateTable2 workTemplateTable2)
    {
        startPage();
        List<WorkTemplateTable2> list = workTemplateTable2Service.selectWorkTemplateTable2List(workTemplateTable2);
        return getDataTable(list);
    }

    /**
     * 导出运用“四种形态”纪律审查情况列表
     */
    @RequiresPermissions("work:templatetable2:export")
    @Log(title = "运用“四种形态”纪律审查情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WorkTemplateTable2 workTemplateTable2)
    {
        List<WorkTemplateTable2> list = workTemplateTable2Service.selectWorkTemplateTable2List(workTemplateTable2);
        ExcelUtil<WorkTemplateTable2> util = new ExcelUtil<WorkTemplateTable2>(WorkTemplateTable2.class);
        return util.exportExcel(list, "templatetable2");
    }

    /**
     * 新增运用“四种形态”纪律审查情况
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存运用“四种形态”纪律审查情况
     */
    @RequiresPermissions("work:templatetable2:add")
    @Log(title = "运用“四种形态”纪律审查情况", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WorkProgressBO workProgressBO)
    {
        return toAjax(workTemplateTable2Service.insertWorkTemplateTable2(workProgressBO));
    }

    /**
     * 修改运用“四种形态”纪律审查情况
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        WorkTemplateTable2 workTemplateTable2 = workTemplateTable2Service.selectWorkTemplateTable2ById(id);
        mmap.put("workTemplateTable2", workTemplateTable2);
        return prefix + "/edit";
    }

    /**
     * 修改保存运用“四种形态”纪律审查情况
     */
    @RequiresPermissions("work:templatetable2:edit")
    @Log(title = "运用“四种形态”纪律审查情况", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WorkTemplateTable2 workTemplateTable2)
    {
        return toAjax(workTemplateTable2Service.updateWorkTemplateTable2(workTemplateTable2));
    }

    /**
     * 删除运用“四种形态”纪律审查情况
     */
    @RequiresPermissions("work:templatetable2:remove")
    @Log(title = "运用“四种形态”纪律审查情况", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(workTemplateTable2Service.deleteWorkTemplateTable2ByIds(ids));
    }

}
